package com.descartes.mymedia.dao.implementation;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.descartes.mymedia.dao.config.EntityManagement;
import com.descartes.mymedia.dao.interfaces.ProfilDAO;
import com.descartes.mymedia.model.Profil;

public class ProfilDAOImpl implements ProfilDAO {

    private EntityManager em;

	public ProfilDAOImpl() {
        em = EntityManagement.getInstance().getEntityManager();
	}

	public Profil getProfil(String pseudo, String mdp) {
		String queryString = "SELECT p FROM Profil p WHERE p.pseudo = :pseudo AND p.mdp = :mdp";
		TypedQuery<Profil> tqProfil = em.createQuery(queryString, Profil.class);
		tqProfil.setParameter("pseudo", pseudo);
		tqProfil.setParameter("mdp", mdp);
		Profil profil = tqProfil.getSingleResult();
		return profil;
	}
	

}
